home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 1 Issue 2 / PDCD-1 - Issue 02.iso / _editors / editors / _zap / !Zap / Docs / E-Entry < prev    next >
Text File  |  1994-10-06  |  33KB  |  680 lines

  1. *************************************************************************
  2. * >E-Entry    Documents the format of a mode entry point table    *
  3. *************************************************************************
  4.  
  5. The offsets in the entry point table are given names beginning 'e_'. The
  6. E-Library program will define the offsets for you.
  7.  
  8. You must fill in the first 8 entries of this table. The rest of the entries
  9. you may leave as 0 (or more simply, set the table length in the 8th word to
  10. 32 bytes). The idea of the mode table, is that you specify a BASE mode. For
  11. all the entry points (from the 9th onwards) that are off the end of your
  12. table, or that you have left as 0, the base mode will be called instead.
  13.  
  14. Hence, the simplest Zap extension mode would just set the base mode as 0 (ie,
  15. TEXT) and leave the rest as 0. You will then get a clone of the text mode.
  16.  
  17. In general the following register conventions are used:
  18.  
  19.     R2    Current column in characters (see E-Windows)
  20.     R3    Current line in characters (see E-Windows)
  21.     R8    Window block pointer / 0 to change the default config
  22.     R9    File block pointer / 0 to change the default config
  23.     R10    Cursor block pointer
  24.     R11    Your extension mode workspace (private word)
  25.     R12    Zaps workspace (private word)
  26.  
  27. In general the entry points have entry and exit conditions:
  28.  
  29.     \E R0-R10=parameters R11=your workspace
  30.        R12=Zap's workspace R13=FD stack R14=return addr
  31.     \X You must save R1-R11 (unless otherwise mentioned).
  32.        You may corrupt R0 and flags.
  33.        Set V flag and put R0=error block pointer on an error.
  34.  
  35. See the E-ZapCalls file for more details on my entry/exit syntax.
  36.  
  37. All offsets given in the table below must be from the start of the module.
  38. Hence the table is relocatable. Zap finds the start address of your module
  39. via the first table entry (e_module). It uses this and an OS_Module call to
  40. determine the address of your workspace (to pass in R11). All strings should
  41. be 0 terminated.
  42.  
  43. Entry points for arbitrary modes may be called using Zap_CallMode,
  44. Zap_CallGivenMode or Zap_BaseMode. If none of these will do, then use
  45. Zap_ReadMode to find the table entry linked points and the address of the
  46. mode's workspace and the entry point can be called directly.
  47.  
  48. Each mode has a word of workspace reserved in the window block (pointed to
  49. by R8) for each file. A mode is responsible for storing the current options
  50. in their mode word when the user changes mode (see e_start/e_end). There
  51. are Zap calls provided to make this easier for you. If you need more than
  52. one word of workspace then the mode word can store the pointer to a block of
  53. workspace if you set a flag in e_mode. See E-Windows (w_mode0...) and E-Vars
  54. (opt_mode0...).
  55.  
  56. The entry points
  57. ================
  58.  
  59. e_module
  60. This gives the table offset from the module start so that the module start
  61. may be calculated by Zap. Ie, module start = address of table start - this
  62. offset.
  63.  
  64. e_title
  65. Offset of the mode title string to be used in the 'Mode' menu. It should be
  66. at most 7 chars long. (eg 'BASIC')
  67.  
  68. e_author
  69. Offset of the author name string (eg 'Dominic Symes').
  70.  
  71. e_basemode
  72. Gives the mode on which to base null entry points. Current modes are: 0=Text
  73. 1=byte 2=word 3=ascii 4=hex 5=basic 6=bastxt 7=cmode 11=throwback
  74. 12=taskwindow. Needless to say, if you wish to clone the BASIC mode, you'd
  75. better be sure that the Zap_Basic module initialised before yours!
  76.  
  77. e_mode
  78. Gives the mode number you would like to be in bits b0-b7. Bits 8-31 contain
  79. flags as follows:
  80.     b8    Set to receive RAW keyboard input. All key presses are sent
  81.         to e_char. Zap key codes greater than &FF are sent as a
  82.         zero byte followed by the low byte.
  83.     b9    Set to get taskwindow style keyboard input passed to e_chars.
  84.         This differs from normal e_chars entry in that:
  85.         1) Delete is passed on as &7F instead of calling e_delete
  86.         2) Characters &20-&FF are passed on regardless of mapping
  87.         3) If not in COPY mode then the cursor keys are passed on
  88.            as a 0 byte followed by bottom 8 bits of the wimp's code.
  89.            Similarly TAB.
  90.         4) Return and Escape are passed on as &0D and &1B.
  91.         This is subject to changes - contact me.
  92.     b10    Set to indicate that you use a mode word in a window block
  93.         (eg w_moden) to point to a block of data. See E-Windows
  94.         for the format this block must take.
  95.     b11    Set to indicate that this is not a 'textual' mode. Eg it's
  96.         like byte/word mode. Setting this bit prevents, for example,
  97.         auto DOS text file detection.
  98.     b31    Set to overwrite any mode already using this mode number.
  99.     Others bits are reserved and should be set to 0.
  100.     If b31 is not set then you are allocated the next free mode if the
  101.     one you wanted is being used.
  102.  
  103. e_init
  104. Called at various points when Zap is starting up/dying or wants to give your
  105. mode a chance to intercept an operation. Note that Zap will automatically
  106. kill your module on dying unless you tell it otherwise. You should use reason
  107. code 2 to claim any buffers from Zap. I am at liberty to add extra reason
  108. codes so please return with all registers unaltered if you receive an
  109. unrecognised code.
  110.     \E R1=reason code (and other registers may hold values dependent on it)
  111.     \X Save R1-R11 as usual unless otherwise stated below.
  112.  The reason codes are:
  113.  R1=0 => Zap is quitting and about to kill your module.
  114.      Return R0=-1 to stop this (eg if you've more than one mode).
  115.  R1=1 => Zap has just started but not set up its heap yet.
  116.       R0=the mode number assigned to your mode.
  117.       You should note the mode number that has actually been assigned to
  118.       you and store it in your module somewhere. This is not guaranteed
  119.       to be the one you asked for.
  120.  R1=2 => Zap has started and set up its heap. On this call you should check
  121.      your mode word opt_moden to see if it's zero. If so then you should
  122.      initialise it to a sensible default value. (See E-Vars) You should
  123.      also use this call to claim any buffers you need.
  124.  R1=3 => Zap is deleting a file with your mode number in f_cmode. R9=file
  125.      block on entry. See E-File.
  126.  R1=4 => Zap is saving a file with your mode number in f_cmode. R8/R9=the
  127.      window being saved. Return R1=-1 if you wish to abort the save
  128.      (and handle it yourself). If you return R1=-1 then return R0=0 if
  129.      the save is safe (file can now be deleted) or -1 if unsafe (entered
  130.      data transfer protocol for example).
  131.  R1=5 => Zap wants to delete a file your mode number in f_cmode, but it
  132.       has the 'altered' flag set. Return R1=-1 to override and allow the
  133.       file to be killed anyway.
  134.  R1=6 => Zap is creating the colours submenu and wants to know what you
  135.       call colours >=9. Return in R1 pointer to a double zero terminated
  136.       list of zero terminated entries giving the names of the colours
  137.       starting from 9. Eg "REMs",0,"Strings",0,0. (Or leave R1 as 6
  138.       if this call is not supported).
  139.  R1=7 => Zap is creating its menus. At this point you can override your
  140.      e_menu value by returning R1 as the pointer to the replacement
  141.      (wimp-style) menu. Leave R1=7 if you don't want to do this.
  142.      You should use Zap_ReadMenu or Zap_LoadMenu to create the menu.
  143.  
  144. e_menu
  145. Offset of submenu in Zap's format / 0 for none. This menu comes off the
  146. 'Mode' menu. See the file E-Menu for details of the menu format. Greater
  147. versitility can be obtained by setting this to 0 and using e_init with R1=7.
  148.  
  149. e_len
  150. Total length of the table data (>=32). (So that only entry points within the
  151. table are called and for forward compatibility). If zap finds an entry point
  152. is off the end of the table then it will call the corresponding base mode
  153. entry point.
  154.  
  155. If any of the following offsets are 0 then the corresponding offset for the
  156. basemode is called.
  157.  
  158. e_postload
  159. Called after a file is loaded and has had a window opened for it in your
  160. mode. It is also called after a file in your mode has been saved. It enables
  161. the file contents to be slightly altered before editing. (eg BASIC encrypts
  162. the line numbers and BASTXT detokenises the program). You may alter the data
  163. directly (ie, you needn't use Zap_Command).
  164.     \E R1=0 => This is a new file which has just been loaded. The window
  165.            hasn't been opened on screen yet so you can alter the file
  166.            directly.
  167.        R1=1 => File has just been saved. You should undo the effect of
  168.               e_presave. (If the effect isn't undone then the redraw
  169.               will be messed up if you don't use Zap_Command etc).
  170.        R8/R9
  171.     
  172. e_presave
  173. Called before the file is saved. It enables file contents to be slightly
  174. altered, undoing the effect of e_postload. (eg BASTXT retokenises the program
  175. prior to saving). As above, you may alter the data directly.
  176.     \E R8/R9
  177.  
  178. e_loading
  179. This is called when a file is loaded off disc for dropping into a window. The
  180. file data is in a heap block. This enables you to change it before insertion
  181. takes place (eg BASTXT detokenises the file). You are only called if the file
  182. type of the file is claimed by your mode (in the 'keys' file).
  183.     \E R2=data length R3=data address
  184.     \X You may change the data, making it larger if necessary
  185.        provided that you enlarge the heap block R3. Return
  186.        updated R2 and R3.
  187.  
  188. e_start
  189. Called when a window enters your mode (eg via Zap_NewMode). You should
  190. restore the current w_flags and w_format options, and any other options you
  191. may have saved in your private word w_moden or block pointed to by w_moden.
  192. The call Zap_RestoreModeWord should be made as this restores the options kept
  193. track of by Zap using Zap_ModeData.
  194.     \E R8/R9=window mode is being changed in OR 0 if the mode on the
  195.          options menu is being changed and you should restore the
  196.          default options, of for example opt_flags and opt_format.
  197.  
  198. e_end
  199. Called when a window leaves your mode (eg via Zap_NewMode). This is similar
  200. to e_start except that you should save the current mode dependent
  201. options from w_format, w_flags. The call Zap_SaveModeWord should be made as
  202. this saves the options kept track of by Zap using Zap_ModeData. Again, if
  203. R8=0 then this all applies to the options menu and opt_flags,opt_format.
  204.     \E R8/R9=window / 0 for iconbar menu
  205.  
  206. e_width
  207. Called when a window is (re)created to find out the width of the work area in
  208. characters (excluding margin). You should read this either from your mode
  209. word or block, or using Zap_ModeData variable number 0 where Zap reserves
  210. space for a width value for you. If you support auto width and the auto width
  211. flag is set (see E-Flags) then you should work this width out from the file.
  212. Once you have calculated the width, it is advisable to store it in w_bpl, a
  213. variable reserved for this purpose.
  214.     \E R8/R9
  215.     \X R0=width of work area in characters (excluding margin)
  216.  
  217. e_linecol
  218. Converts a column offset on screen to file offset. This is called by
  219. Zap_FindOffset and other subs. The start offset of the physical line on which
  220. the column lies has been calculated (usually by e_clnoff).
  221.     \E R0=file offset of physical line start
  222.        R1=column offset on screen (exc margin) R8/R9
  223.     \X R0=file offset of nearest character on the left
  224.         
  225. e_lineoff
  226. Convert file offset to column on screen. This performs the inverse function
  227. to e_linecol. It is usually called by Zap_OffLineCol. Again the offset of the
  228. start of the physical line has been calculated (usually by e_clnphy). This
  229. call should also return the caret width for this mode.
  230.     \E R0=file offset of physical line start
  231.        R1=file offset (to convert to a column) R8/R9
  232.     \X R0=column offset on screen (exc margin)
  233.        R1=caret width (in characters - usually 1).
  234.  
  235. The next 3 subs do the main body of work of converting between screen display
  236. lines and file offsets. A physical line means the actual offset in lines from
  237. the top of the file when displayed - that is the actual 'y' coordinate.
  238. Counting starts at 0. Logical lines can be interpreted however the mode
  239. wishes. In text mode, a logical line is ended by a return (as opposed to the
  240. display wrapping). These are given as offsets from 0 as the first line. It is
  241. important that these routines are OPTIMISED as much as possible.
  242.  
  243. e_clnlog
  244. Converts a logical line number to a file offset/physical line. This is not as
  245. important as the other two. It is mainly used by the 'GOTO' box (F5). Ie,
  246. user asks to go to logical line (eg basic line) 500 and Zap wants to know the
  247. file offset of this.
  248.     \E R0=logical line number R8/R9
  249.     \X R0=file offset of line start
  250.        R1=physical line number
  251.  
  252. e_clnphy
  253. This converts a physical line number to a file offset. This is the most
  254. important of the 3 as it is called when updating a window. For example the
  255. wimp asks zap to redraw a rectangle. The top of the rectangle is at physical
  256. line 100 say. Zap needs to know the file offset of this line to call
  257. e_redrawline. It uses this call. Do NOT start counting from the start of the
  258. file, as the window being updated may be near the end. Instead, use the start
  259. of the w_txt cache as a reference. Ie, use the variables w_cline, w_coff,
  260. w_clogl as your start reference.
  261.     \E R0=physical line number R8/R9
  262.     \X R0=file offset of line start
  263.        R1=logical line number
  264.  
  265. e_clnoff
  266. Converts a file offset to a line number and offset. This call is used by
  267. Zap_OffLineCol and when a window is first opened. It should find out which
  268. physical line a file offset lies on. If the file offset is equal to the file
  269. length then it should return the line of an 'imaginary' last character. This
  270. is called when a window is initially opened to work out the w_height value.
  271. As with e_clnphy you should use the cache reference point as a starting
  272. point.
  273.     \E R0=file offset R8/R9
  274.     \X R0=physical line number
  275.        R1=file offset of physical line start
  276.        R2=logical line number
  277.  
  278. e_nextline
  279. This is called during a Zap_DoCommand operation. It is designed to work out
  280. the first line on screen which can be shifted down, following an insertion/
  281. deletion, without being redrawn. On entry you are told the first character
  282. which occurs after the altered region and the amount by which its offset will
  283. change due to the alteration. You must return the file offset of the first
  284. line which may be shifted on the screen without being redrawn. (Usually the
  285. first logical line with start offset > R0). In the case where there is no
  286. such line, return the end of file offset and the physical line containing
  287. this 'imaginary' character offset (as for e_clnoff).
  288.  See also e_prevline. e_prevline is called first, and the file block is
  289. set up as for e_prevline.
  290.     \E R0=file offset of first 'shiftable' character
  291.        R1=signed change in file offset of this character R8/R9
  292.     \X R0=file offset of first 'shiftable' line
  293.        R1=physical line number of this line #
  294.        You must preserve the split offset and split size of the file.
  295.        
  296. e_minus
  297. This is called when the user presses the left arrow key to work out the next
  298. cursor position. The buffering is done for you.
  299.     \E R0=physical line start file offset
  300.        R1=cursor file offset
  301.        R2=cursor column (exc margin) R8/R9
  302.        R10=cursor caret block
  303.     \X If R2>=0 then R1,R2 given new cursor position on the
  304.        same physical line.
  305.        If R2=-1 then R1=new file offset of cursor.
  306.        If R2=-2 then you have moved the cursor yourself.
  307.        If R2=-3 then R0,R1=new x,y for cursor.
  308.  
  309. e_plus        Perform cursor right (\E & \X as for e_minus)
  310. e_sminus    Perform cursor back a word (\E & \X as for e_minus)
  311. e_splus        Perform cursor forward a word (\E & \X as for e_minus)
  312. e_cminus    Move cursor to line start (\E & \X as for e_minus)
  313. e_cplus        Move cursor to line end (\E & \X as for e_minus)
  314.  
  315. e_redrawline
  316. This is called when your mode is required to redraw one (physical) line of
  317. the display - it is also here that you can specify the colour of each
  318. character. You are passed:
  319.  1) As input:
  320.     The physical line start (calculated via e_clnphy - or the previous call
  321.     to this sub). This is not passed as a file offset, but as an actual
  322.     ADDRESS in the file buffer (in R7). Recalling the split nature of the
  323.     buffer (see E-File) the text may not be continuous. R10 is set to the
  324.     end of this section of the split so the file is continuous up to R10.
  325.     R5=R7-the offset of the character - I call this the apparent buffer start
  326.     (where the start would be if the file were continuous).
  327.  2) For output:
  328.     The address of a buffer (in R6) in which to write the characters to
  329.     appear on the line (one byte per character). This buffer has been
  330.     cleared to spaces beforehand so you only need to write the non-space
  331.     characters. Line numbers have been dealt with. You told Zap the width
  332.     the buffer should be when your e_width entry point was called.
  333.  3) Colours:
  334.     As far as this call is concerned there are up to 256 colours (numbered
  335.     0-255) available. Numbers 0-8 have a standard meaning and 9+ can be
  336.     declaired for use by the mode (see e_init with R1=6/Zap_ModeColourNum).
  337.     These colour numbers bear no resemblance to wimp colour numbers, but are
  338.     'internal' Zap colour numbers. Their actual physical appearance is chosen
  339.     by the user from the colours menu - and can be selected from a
  340.     palette. Colours 0-8 have a standard interpretation but colours 9+
  341.     can be used as the mode sees fit. Eg, colour 9 may be used for IF
  342.     statements in a language editor for example. The standard colours are
  343.         0=Background colour 1 (default background colour + off end of text)
  344.         1=Background colour 2 (this should be used under text)
  345.         2=Standard foreground colour
  346.         3/4=selection bac/foreground 5/6=cursor bac/foreground
  347.         7=line numbers 8=control characters.
  348.     Let n be the value stored in [R8,#w_txtw]. Then the foreground colour of
  349.     the cached character stored at R6 is stored at R6+n and the background
  350.     colour at R6+2*n. These are initially cleared to bytes '2' and '0'
  351.     respectively - you should overwrite these bytes to change the colour.
  352.     Text mode puts colour 1 (background colour 2) under actual text and you
  353.     should do the same. See e_init for how to change the colours menu.
  354.  4) Other comments:
  355.     On exit you should update several registers to the start of the next
  356.     physical line. e_clnphy is only called for the first line in a group.
  357.     For a simple example of how to write this redraw code, see the code for
  358.     mode 3 (ascii mode).
  359.     \E R4=w_format (read from R8,#w_format)
  360.        R5=apparent buffer start (R7-offset of char in file)
  361.           (so it is either f_ptr or f_ptr+f_splits)
  362.        R6=address of cache line to draw line in (already blanked)
  363.        R7=address of start of (source) line (R5+file offset of line).
  364.        R8/R9
  365.        R10=address of end of this section of the buffer.
  366.            (so when you reach R10 you increase R5 and R7 by f_splits if
  367.            at the end of the first half or stop if at the file end).
  368.        R11=logical line number (for you to update for cache reference
  369.            and printing in the left hand column).
  370.     \X R0-R4,R6,R10 may be corrupted
  371.        R5,R7,R11 must be updated to the start of the next physical line
  372.     á  R8-R9,R12 must be preserved
  373.  
  374. e_redrawlnum
  375. This is called when the user wishes logical line numbers to be displayed on
  376. the left. You must decide whether the given physical line file offset it at
  377. the start of a logical line. This is called while redrawing the line numbers.
  378.     \E R7=file offset of start of physical line
  379.        R11=proposed logical line number (as calculated by e_clnphy)
  380.        R8/R9
  381.     \X CC if R7 is at the start of a logical line (so print it)
  382.        CS if the line number column should be left blank
  383.        You may corrupt R0-R4. You may also change R11 as BASIC does
  384.        but this is not advised as the w_clogl will get out of sync.
  385.        BASIC ignores the w_clogl as the line number is stored in the
  386.        file.
  387.  
  388. e_char
  389. This is called when the user types a string of ascii chars via the CHAR
  390. command. The characters have been concatenated for you. You should perform
  391. the relevant insertions/deletions via Zap_Command.
  392.     \E R4=w_flags
  393.        R5=number of bytes typed
  394.        R6=w_format
  395.        R7=address of typed data
  396.        R8-R10=input caret (ie this points to the block car_cursor or
  397.               car_input depending on the caret mode and where typed
  398.               text should go).
  399.     \X You may corrupt R0-R11
  400.  
  401. e_delete
  402. This is called when the user executes the commands DELETE or DELETENEXT. A
  403. sequence of deletes is concatenated for you. You should use Zap_Command to
  404. delete the text. Try and support the line edit mode.
  405.     \E R5=number of times pressed
  406.        R6=w_format
  407.        R7=0 for DELETE/1 for DELETENEXT
  408.        R8-R10=input caret
  409.     \X You may corrupt R0-R11
  410.  
  411. e_tab
  412. This is called when the user executes the command TAB. As usual, repetitions
  413. are concatenated. Use Zap_Command to perform the function.
  414.     \E R1=number of times pressed
  415.        R8-R10=input caret
  416.     \X You may corrupt R0-R11
  417.  
  418. e_return    Called when RETURN executed (\E \X as for e_tab)
  419. You should insert an appropriate number of newlines - remember to take
  420. account of the buffering in R1.
  421.  
  422. e_renumber    Called when RENUMBER executed (\E \X as for e_tab)
  423. You should renumber/restyle the program - language specific.
  424.  
  425. e_saveandrun    Called when SAVEANDRUN executed (\E \X as for e_tab)
  426. You should save the program and then run it so that the program quits when
  427. finished. This will often duplicate e_compile.
  428.  
  429. The next 4 subs are used by the various delete line calls. They each have
  430.     \E R0=current file offset in a line R8/R9
  431.     \X R0=new file offset (see below)
  432. This is how the subs are called:
  433.  
  434. DELLINE        Deletes from lineprev to linenext offsets.
  435. DELTOEND    Deletes from current offset to lineend unless this is empty
  436.         when it calls JOINLINE (as in emacs ctrl K)
  437. DELTOSTART    Deletes from linestart to current offset unless empty.
  438.  
  439. e_linestart    Called to find the lines first character.
  440. e_lineend    Called to find the lines last character.
  441. e_linenext    Called to find the lines actual end (eg after &0A)
  442. e_lineprev    Called to find the lines actual start (eg for basic lines)
  443.  
  444. e_copy
  445. Called when user wishes to copy characters via the COPY key. Is is called for
  446. finding the characters to copy and for inserting the copied characters.
  447. Reason code is in R0. When reading characters you must update the cursor
  448. yourself. Note the source window may be in a different mode to the
  449. destination window!
  450.         \E R0=1 => Fetch characters
  451.            R1=number of times copy pressed (number of chars to get)
  452.            R8-R10=copy cursor (car_cursor)
  453.         \X R3=pointer to buffer containing characters to 'type'
  454.            R2=number of characters to 'type'
  455.            Copy cursor updated to new position
  456.         OR
  457.         \E R0=2 => Write copied characters
  458.            R2=number of chars to type
  459.            R3=pointer to the chars
  460.            R8-R10=input cursor (car_input)
  461.         \X R0=0 means you've done it all yourself
  462.            R0=1 means please enter it for me via Zap_Command
  463.            R0=2 means please enter it for me by calling my e_chars
  464.  
  465. e_joinline    This is called when Joinline pressed (\E \X as for e_tab)
  466. e_splitline    This is called when Splitline pressed (\E \X as for e_tab)
  467.  
  468. e_aligncaret
  469. This is called before any commands are executed on a window in your mode.
  470. It serves two purposes. The first is to align the input caret offset to a
  471. sensible position (eg word align in word mode, put after line numbers in
  472. basic). The second is to reset any counters you may have. For example, the
  473. hex mode entry uses a counter to tell how many nibbles have been inserted in
  474. a word. This is cleared on e_aligncaret with the old value being saved. Then
  475. if the command 'insert 9' is executed it can retrieve and restore the saved
  476. value. If any other command is executed (eg LEFT) then the counter will
  477. remain reset.
  478.     \E R8-R10=caret
  479.     \X Input caret offset [R10,#c_off] can be updated.
  480.  
  481. e_command
  482. This entry point is called whenever anyone issues a Zap_Command call, or
  483. equivalent, to try and alter a file in a window in your mode. The easiest way
  484. to deal with this is to pass the call onto Zap_DoCommand which will perform
  485. the alteration. However, if you support wordwrap, you may wish to 'fiddle'
  486. the data, or even perform additional operations.
  487.     \E As for Zap_Command
  488.  
  489. e_compile    This is called when Compile pressed    (\E \X as for e_tab)
  490. The mode should save the file to disc and then try to compile/run it.
  491.  
  492. e_formattext    This is called when Formattext pressed    (\E \X as for e_tab)
  493. The mode should try and format the current paragraph for its particular
  494. language.
  495.  
  496. e_run        This is called when Run pressed        (\E \X as for e_tab)
  497. The mode should try and run the program without saving it. Revert to
  498. e_compile code if there is no difference.
  499.  
  500. e_runandquit    This is called when Runandquit pressed    (\E \X as for e_tab)
  501. This should act as e_run but add a -quit option if possible.
  502.  
  503. e_basic        This is called when Basic pressed    (\E \X as for e_tab)
  504. This should drop the file into the command line state of the current
  505. language.
  506.  
  507. e_search
  508. This handles string searches in your mode. When the 'Raw search' option is on
  509. the file is searched directly and the mode has no control over it. When, as
  510. usual, the option is off the the text is searched through in lines. Each mode
  511. has a chance to turn a line of the file into meaningfull text. For example,
  512. BASIC mode will detokenise the line and Code mode will disassemble the
  513. instruction. Unrecognised reason codes should be ignored (and registers
  514. preserved). After the line has been searched you are called again to convert
  515. a match to a file offset and/or specify the start/end of the next line to
  516. search (depending on the search direction).
  517.     \E R1=reason code
  518.           0 = starting a search - now obsolete and no longer used.
  519.           1 = match found - now obsolete and no longer used.
  520.           2 = starting search in a line (non 'raw' search)
  521.               Then R3=file offset of current search position
  522.                    R4=search direction (+1/-1)
  523.                    R8/R9=the window being searched
  524.               \X Preserve R1+ to use the standard text search routine
  525.                  or set R1=pointer to 'detokenised line' string.
  526.                 R2=offset in the string of the search posn.
  527.                 R3=file offset of the start of the line.
  528.                 R10=length of the string pointed to by R1.
  529.           3 = has finished searching through this line. You are called
  530.               with:
  531.            R1=pointer to 'detokensied string'
  532.            R2=offset in the string of the match/-ve if not found
  533.            R3=offset in the file of the start of the line
  534.            R4=search direction (+1/-1)
  535.            R8/R9=the window being searched
  536.            R10=length of the line
  537.           \X Preserve registers for default action. Otherwise
  538.           if a match has been found (R2 +ve) then you should set
  539.            R1=0
  540.            R2=file offset of the match
  541.            R3=next file offset to look at (usually R2+R4)
  542.           if a match was not found you should set
  543.            R1=0
  544.            R2=-ve (ie preserve it)
  545.            R3=next file offset to look at (usually R3+R10 or R3-1)
  546.           the search will be aborted (or move onto the next file if
  547.           R3<0 or R3>=file length).
  548.           4 = has found a match and wants to know the file offset of the
  549.               end of the match. This is called before the call with R1=3
  550.               to find the start. You are called with registers as set
  551.               up for R1=3 except R2=offset in the string of match end.
  552.               \X As for R1=3 except R2=file offset of end of match
  553.               and R3 is not used (you may corrupt it).
  554.               [Usually you will call the same code for R1=3 or 4]
  555.           5+ = reserved
  556.  
  557. e_replace
  558. This is called when the user wishes to perform a search and replace. The
  559. replacement string has been calculated for you and it is your job to insert
  560. it. Your default action should be to call Zap_ReplaceArea.
  561.     \E R1=file offset (of match)
  562.        R2=length (of match)
  563.        R3=replacement data
  564.        R4=replacement length. R8/R9
  565.  
  566. e_selection
  567. This handles region selections/saving. You should check the validity of the
  568. selected area, confining it to lines/paragraphs if you wish.
  569.     \E R0=reason code R8/R9=window
  570.        R0=0 => starting selection
  571.            R10=proposed start caret. You can use the variable car_mode
  572.            to find out if the selection is mouse or keyboard (E-Vars).
  573.        R0=1 => updating selection size
  574.            R10=new selection block (car_selection)
  575.             You may alter the contents of the selection block.
  576.        R0=2 => saving selection
  577.            R3=data address (a heap block)
  578.            R2=data len
  579.                R4=proposed filetype
  580.             You may change these provided R3 remains a heap block.
  581.             (eg BASIC will tokenise it).
  582.  
  583. e_click
  584. This is called when the user clicks on your window. Default action should be
  585. to call Zap_DefaultClick which will handle R1=0,1 and ignore the rest. Clicks
  586. are registered to any depth so you should modulo the click number with the
  587. number of useful actions you support so they cycle round. Drags are also
  588. passed to you. If the user drags straight away (ie after 1 click) then you
  589. will be sent R1=0. If the user drags after a double click then you will
  590. be sent R1=2 and b3 of R4 will be set. After treble click R1=3 etc.
  591.     \E R1=click depth (0=simple drag 1=single click 2=double click etc)
  592.        R2=x column (including margin)
  593.        R3=y row of click in work area characters
  594.        R4=buttons   b0=adjust pressed
  595.                b1=undefined (menus are dealt with by Zap)
  596.                b2=select pressed
  597.                b3=drag after two or more clicks (given in R1)
  598.                b4-b31=reserved
  599.        R8/R9=window clicked on
  600.  
  601. e_message
  602. This entry point is called when an unrecognised wimp message is received by
  603. Zap. The message is broadcast to all modes. Please IGNORE (ie return) unless
  604. you understand the message number and the window handle!!
  605.     \E R0=your mode number
  606.        R1=message block (as sent by wimp)
  607.        R2=R1!16=message number if R3=17 or 19
  608.        R3=message type
  609.           (Null requests are scheduled - use Zap_CallBack)
  610.           1=redraw window request for unrecognised window
  611.           2=open window request for unrecognised window
  612.           3=close window request for unrecognised window
  613.           4=pointer leaving unrecognised window
  614.           5=pointer entering unrecognised window
  615.           6=mouse click on unrecognised window
  616.           (Drags dealt with by Zap - use Zap_DragBox)
  617.           8=key press for unrecognised window
  618.           (Menu clicks handled automatically - use Zap_OpenMenu)
  619.           10=scroll request for unrecognised window
  620.           11=lose caret for unrecognised window
  621.           12=gain caret for unrecognised window
  622.           13-16=passed straight on (not recognised by Zap)
  623.           17=unrecognised user message (or recognised message applying
  624.              to unrecognised window)
  625.           (type 18 gets passed on as 17 as well)
  626.           19=unrecognised bounced message
  627.           20+=passed straight on (not recognised by Zap)
  628.  
  629. e_setwidth
  630. This entry point is used by the SETWIDTH command (Ctrl W) and the 'width'
  631. menu option on the display menu. It is called to read the currently
  632. configured width for this mode (of a window or the default according to R8),
  633. or in order to set the currently configured width. You should access this
  634. width by looking at your mode word w_moden if that's where you keep it, or
  635. using Zap_ModeData if you keep it in the place provided by Zap (this is the
  636. default action of the text mode entry point). Following this call, the editor
  637. window in question will be recreated automatically and your e_width entry
  638. point will be called to calculate the actual display width as usual.
  639.     \E R0=new width user wants or -1 to read the current width
  640.        R8-R9=window/0 if it is the default width being changed.
  641.     \X R0=current width if it was -1 on entry.
  642.  
  643. e_listfns
  644. This is called when the command LISTFNS is pressed. \E \X as for e_tab. The
  645. mode should open a throwback buffer with a list of function definitions in.
  646. (eg Use Zap_Search).
  647.  
  648. e_prevline
  649. This entry point is used in conjunction with e_nextline to find the area on
  650. the screen which needs to be updated after an insertion/deletion. It tells
  651. you in R0 the first file offset being changed and you must tell it the first
  652. file offset (<=R0) to start updating the screen from. Usually you will just
  653. leave R0 unchanged but in the case of a mode using colours - where changing a
  654. character later on in the line may affect earlier colours - you may want to
  655. set this to the start of the current logical line. The cache reference point
  656. (w_cline/w_coff) is moved so that it is most R0, and is thus not corrupted by
  657. the insertion/deletion. If you wish to move it further back (eg if a control
  658. code later in a line effects the formatting of earlier bits) then now is the
  659. time to do so - via Zap_ClipCache.
  660.  e_prevline is called before e_nextline. Complicated colouring modes (eg
  661. colour C mode) need to know what data is being inserted/deleted to decide
  662. what to return for e_prevline/e_nextline. To make this possible, the
  663. follwing data is available:
  664.  f_docom=the command currently being executed:
  665.  0,>5=none   => text not changing (just return with R0 preserved).
  666.  1=insertion => R0=offset that text is being inserted at
  667.          f_dolen=number of characters being inserted
  668.          f_dodata=pointer to the text being inserted
  669.          File is split at the offset R0 with split size >= f_dolen.
  670.  2=deletion  => R0=offset of start of block to delete
  671.          f_dolen=number of characters being deleted
  672.          File is split at R0+f_dolen with split size >=0.
  673.  3/4=replace => R0=offset of start of block to replace
  674.          f_dolen=number of characters to replace
  675.          f_dodata=replacement block
  676.          File is split at R0+f_dolen with split size >= f_dolen.
  677.     \E R0=First changed offset in the file. R8/R9
  678.     \X R0=Offset to start updating the screen from.
  679.        You must preserve the split offset and split size of the file.
  680.